package dtm

const (
	ApiType           string = "dtmapi.protocol.CmdAuth, dtmapi.protocol"
	ErrorCode         int    = 0
	PenType           string = "dtmapi.protocol.CmdGetPenList, dtmapi.protocol"
	RecipeType        string = "dtmapi.protocol.CmdGetRecipeList, dtmapi.protocol"
	RecipeDetailType  string = "dtmapi.protocol.CmdGetRecipe, dtmapi.protocol"
	SpreadingType     string = "dtmapi.protocol.CmdGetUnloadRangeList, dtmapi.protocol"
	SpreadingByIdType string = "dtmapi.protocol.CmdGetUnload, dtmapi.protocol"
	LoadDataType             = "dtmapi.protocol.CmdGetLoad, dtmapi.protocol"
)

type AuthRequest struct {
	Type         string `json:"$type"`
	CompanyCode  string `json:"CompanyCode"`
	ResellerCode string `json:"ResellerCode"`
	Pwd          string `json:"Pwd"`
}

type AuthResponse struct {
	Type            string `json:"$type"`
	CompanyCode     string `json:"CompanyCode"`
	ApiWebSericeUrl string `json:"ApiWebSericeUrl"`
	SessionId       string `json:"SessionId"`
	IsCustomerUser  bool   `json:"IsCustomerUser"`
	ErrorCode       int    `json:"ErrorCode"`
}

type PenListRequest struct {
	Type        string `json:"$type"`
	CompanyCode string `json:"CompanyCode"`
	SessionId   string `json:"SessionId"`
	FromDate    string `json:"FromDate"`
}

type PenListResponse struct {
	Type      string       `json:"$type"`
	Values    *ValuesModel `json:"Values"`
	ErrorCode int          `json:"ErrorCode"`
}

type ValuesModel struct {
	Type   string `json:"$type"`
	Values []int  `json:"$values"`
}

type RecipeListRequest struct {
	Type        string `json:"$type"`
	SessionId   string `json:"SessionId"`
	CompanyCode string `json:"CompanyCode"`
	FromDate    string `json:"FromDate"`
}

type RecipeListResponse struct {
	Type      string       `json:"$type"`
	Values    *ValuesModel `json:"Values"`
	ErrorCode int          `json:"ErrorCode"`
}

type RecipeDetailRequest struct {
	Type        string `json:"$type"`
	RecipeId    int    `json:"RecipeId"`
	SessionId   string `json:"SessionId"`
	CompanyCode string `json:"CompanyCode"`
}

type RecipeDetailResponse struct {
	Type      string             `json:"$type"`
	Value     *RecipeDetailValue `json:"Value"`
	ErrorCode int                `json:"ErrorCode"`
}

type RecipeDetailValue struct {
	Type                   string                  `json:"$type"`
	RecipeId               int                     `json:"RecipeId"`
	RecipeIdAdmin          string                  `json:"RecipeIdAdmin"`
	RecipeExternalKey      string                  `json:"RecipeExternalKey"`
	Name                   string                  `json:"Name"`
	RecipeMajorRevision    int                     `json:"RecipeMajorRevision"`
	RecipeMinorRevision    int                     `json:"RecipeMinorRevision"`
	Premix                 bool                    `json:"Premix"`
	MixingTime             int                     `json:"MixingTime"`
	RowVersion             string                  `json:"RowVersion"`
	RevData                string                  `json:"RevData"`
	MixingSpeedScrewRecipe float64                 `json:"MixingSpeedScrewRecipe"`
	HighSpeedScrewRecipe   bool                    `json:"HighSpeedScrewRecipe"`
	RecipeDensity          float64                 `json:"RecipeDensity"`
	Components             *RecipeDetailComponents `json:"Components"`
}

type RecipeDetailComponents struct {
	Type   string                         `json:"$type"`
	Values []*RecipeDetailComponentsValue `json:"$Values"`
}

type RecipeDetailComponentsValue struct {
	Type                            string  `json:"$type"`
	RecipeId                        int     `json:"RecipeId"`
	Name                            string  `json:"Name"`
	ComponentId                     int     `json:"ComponentId"`
	ComponentIdAdmin                string  `json:"ComponentIdAdmin"`
	WeightCow                       float64 `json:"WeightCow"`
	DMPerc                          float64 `json:"DMPerc"`
	WeightDMCow                     float64 `json:"WeightDMCow"`
	PriceCow                        float64 `json:"PriceCow"`
	StartMixComp                    bool    `json:"StartMixComp"`
	TMisc                           int     `json:"TMisc"`
	Position                        int     `json:"Position"`
	PercWeightCow                   float64 `json:"PercWeightCow"`
	TotalWeight                     float64 `json:"TotalWeight"`
	CounterKnivesComponent          bool    `json:"CounterKnivesComponent"`
	CycleAutoCounterKnivesComponent bool    `json:"CycleAutoCounterKnivesComponent"`
	CycleTimeComponent              int     `json:"CycleTimeComponent"`
	MixingActiveScrewStartComponent bool    `json:"MixingActiveScrewStartComponent"`
	MixingSpeedScrewComponent       float64 `json:"MixingSpeedScrewComponent"`
	HighSpeedScrewComponent         bool    `json:"HighSpeedScrewComponent"`
}

type CreatePenResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type SpreadingRequest struct {
	Type        string `json:"$type"`
	SessionId   string `json:"SessionId"`
	CompanyCode string `json:"CompanyCode"`
	FromDate    string `json:"FromDate"`
	ToDate      string `json:"ToDate"`
}

type SpreadingResponse struct {
	Type      string       `json:"$type"`
	Values    *ValuesModel `json:"Values"`
	ErrorCode int          `json:"ErrorCode"`
}

type SpreadingByIdRequest struct {
	Type        string `json:"$type"`
	SessionId   string `json:"SessionId"`
	CompanyCode string `json:"CompanyCode"`
	UnloadId    int    `json:"UnloadId"`
}

type SpreadingByIdResponse struct {
	Type      string       `json:"$type"`
	Value     *UnloadModel `json:"Value"`
	ErrorCode int          `json:"ErrorCode"`
}

type UnloadModel struct {
	Type                string             `json:"$type"`
	UnloadId            int                `json:"UnloadId"`
	LoadId              int                `json:"LoadId"`
	Name                string             `json:"Name"`
	StartTime           string             `json:"StartTime"`
	EndTime             string             `json:"EndTime"`
	Duration            string             `json:"Duration"`
	RecipeId            int                `json:"RecipeId"`
	Recipe              string             `json:"Recipe"`
	BatchId             int                `json:"BatchId"`
	BatchExternalkey    string             `json:"BatchExternalkey"`
	BatchName           string             `json:"BatchName"`
	TotalTargetWeight   float64            `json:"TotalTargetWeight"`
	TotalUnloadedWeight float64            `json:"TotalUnloadedWeight"`
	TotalErrorPerc      float64            `json:"TotalErrorPerc"`
	UnloadedPens        *UnloadedPensModel `json:"UnloadedPens"`
}

type UnloadedPensModel struct {
	Type   string                    `json:"$type"`
	Values []*UnloadedPensValueModel `json:"$values"`
}

type UnloadedPensValueModel struct {
	Type                       string                   `json:"$type"`
	PenUnloadId                int                      `json:"PenUnloadId"`
	PenId                      int                      `json:"PenId"`
	Name                       string                   `json:"Name"`
	AnimalNumber               int                      `json:"AnimalNumber"`
	TotalTargetWeight          float64                  `json:"TotalTargetWeight"`
	TotalUnloadedWeight        float64                  `json:"TotalUnloadedWeight"`
	ErrorPerc                  float64                  `json:"ErrorPerc"`
	UnloadedChemicalParameters *ChemicalParametersModel `json:"UnloadedChemicalParameters"`
}

type ChemicalParametersModel struct {
	Type   string                          `json:"$type"`
	Values []*ChemicalParametersValueModel `json:"$values"`
}

type ChemicalParametersValueModel struct {
	Type           string  `json:"$type"`
	NirParameterID int     `json:"NirParameterID"`
	Name           string  `json:"Name"`
	Value          float64 `json:"Value"`
}

type LoadDataByIdRequest struct {
	Type        string `json:"$type"`
	LoadId      int    `json:"LoadId"`
	SessionId   string `json:"SessionId"`
	CompanyCode string `json:"CompanyCode"`
}

type LoadDataByIdResponse struct {
	Type      string    `json:"$type"`
	Value     *LoadData `json:"Value"`
	ErrorCode int       `json:"ErrorCode"`
}

type LoadData struct {
	Type              string            `json:"$type"`
	LoadId            int               `json:"LoadId"`
	Name              string            `json:"Name"`
	StartTime         string            `json:"StartTime"`
	EndTime           string            `json:"EndTime"`
	Duration          string            `json:"Duration"`
	RecipeId          int               `json:"RecipeId"`
	BatchId           int               `json:"BatchId"`
	ExternalBatchKey  interface{}       `json:"ExternalBatchKey"`
	BatchName         string            `json:"BatchName"`
	TotalTargetWeight float64           `json:"TotalTargetWeight"`
	TotalLoadedWeight float64           `json:"TotalLoadedWeight"`
	TotErrorPerc      float64           `json:"TotErrorPerc"`
	MachineId         int               `json:"MachineId"`
	MachineName       string            `json:"MachineName"`
	TargetCostOnScale float64           `json:"TargetCostOnScale"`
	LoadCost          float64           `json:"LoadCost"`
	LoadedComponents  *LoadedComponents `json:"LoadedComponents"`
}

type LoadedComponents struct {
	Type   string                   `json:"$type"`
	Values []*LoadedComponentValues `json:"$values"`
}

type LoadedComponentValues struct {
	Type                     string                    `json:"$type"`
	ComponentLoadId          int                       `json:"ComponentLoadId"`
	ComponentId              int                       `json:"ComponentId"`
	Name                     string                    `json:"Name"`
	TotalTargetWeight        float64                   `json:"TotalTargetWeight"`
	TotalLoadedWeight        float64                   `json:"TotalLoadedWeight"`
	OperatorErrorPerc        float64                   `json:"OperatorErrorPerc"`
	TotalTargetCost          float64                   `json:"TotalTargetCost"`
	TotalLoadedCost          float64                   `json:"TotalLoadedCost"`
	LoadedChemicalParameters *LoadedChemicalParameters `json:"LoadedChemicalParameters"`
}

type LoadedChemicalParameters struct {
	Type   string                            `json:"$type"`
	Values []*LoadedChemicalParametersValues `json:"$values"`
}

type LoadedChemicalParametersValues struct {
	Type           string  `json:"$type"`
	NirParameterID int     `json:"NirParameterID"`
	Name           string  `json:"Name"`
	Value          float64 `json:"Value"`
}
